package com.zryc;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * Hello world!
 *
 */
//注册为spring boot应用程序
@SpringBootApplication
//开启mapper扫描，并指定Mapper接口所在的包
@MapperScan("com.zryc.mapper")
//开启服务注册功能
@EnableDiscoveryClient
//启用Feign客户端，就可以使用Feign组件进行远程服务的调用
@EnableFeignClients
public class OrderApp
{
//    @Bean
//    public FilterRegistrationBean sentinelFilterRegistration() {
//        FilterRegistrationBean registration = new FilterRegistrationBean();
//        registration.setFilter(new CommonFilter());
//        registration.addUrlPatterns("/*"); // 入口资源关闭聚合
//        registration.addInitParameter(CommonFilter.WEB_CONTEXT_UNIFY, "false");
//        registration.setName("sentinelFilter");
//        registration.setOrder(1); return registration;
//    }
    //为服务消费模块注入一个Bean (RestTemplate),可以借助于它去调用别的服务
    @Bean
    @LoadBalanced //启动Ribbon负载均衡器
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }
    public static void main( String[] args )
    {
        SpringApplication.run(OrderApp.class,args);
    }
}
